<template>
 <div class="count">
 
 
       <button @click="obj.buycount > 1 && obj.buycount --" type="button" class="btn btn-light" >-</button>
        <input type="number" class="form-control inp" v-model.number="obj.buycount">
     <button type="button" @click="obj.buycount++" class="btn btn-light">+</button>
  <div class="delete-1"  @click="deletee(obj)">移除</div>
  </div>
</template>

<script>
import axios from "axios"
export default {
  props: {
    obj:Object
  },
  data () {
    return {
      list:[]
    }
  },
  watch: {
    obj:{
      deep:true,
      handler(){//判断小于1 修改成1
        if (this.obj.buycount <1) {
          this.obj.buycount = 1
        }
      }
    }
  },
   created() {
      this.getquredis()
    },
  methods: {
    getquredis(obj){
      axios({
        url: "/api/product/getquredis",
        params: this.params,
        method: "GET",
      }).then((res) => {
        console.log(res);
        this.list = res.data;
      });
  },

    deletee(obj){
        axios({
        url: "/api/product/deletee",
        method: "GET",
        params:{
          id:obj.id,
          userId:JSON.parse(localStorage.getItem('user')).userId,
        }
      }).then((res) => {
        alert("删除成功")
        this.getquredis()
        if (location.href.indexOf("#reloaded") == -1) {
            location.href = location.href + "#reloaded";
            location.reload();
          }
      });
    }
  }
 
}
</script>

<style lang="less" scoped>

.delete-1{
background-color: red;
border-radius: 30px;
float: left;
margin-top: -40px;
height: 25px;
font-size: 10px;
text-align: center;
color: #fff;
width: 50px;

}
 .count{
        display: flex;
        .inp{
            width: 45px;
            text-align: center;
            margin: 0 5px;
        }
        .btn, .inp{
            // 
    transform: scale(0.7);
    width: 15px;
  }
    }
    
</style>